From 1e2a54cee2fcb2f0fc15fd83c1014e1813eb75df Mon Sep 17 00:00:00 2001
From: Guido Ranzuglia <guido.ranzuglia@isti.cnr.it>
Date: Mon, 9 Jan 2017 17:51:01 +0100
Subject: [PATCH] - added locale support to MeshLab&MeshLabServer -fixed "not
 enough memory" bug in MeshLabServer

---
 src/meshlab/main.cpp             |  2 ++
 src/meshlabserver/mainserver.cpp | 21 ++++++++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/meshlab/main.cpp b/src/meshlab/main.cpp
index eee69b9..068e8ab 100644
--- a/src/meshlab/main.cpp
+++ b/src/meshlab/main.cpp
@@ -24,11 +24,13 @@
 #include <QMessageBox>
 #include "mainwindow.h"
 #include <QString>
+#include <clocale>
 
 int main(int argc, char *argv[])
 {
 
     MeshLabApplication app(argc, argv);
+	std::setlocale(LC_ALL, "C");
     QLocale::setDefault(QLocale::C);
     QCoreApplication::setOrganizationName(MeshLabApplication::organization());
 #if QT_VERSION >= 0x050100
diff --git a/src/meshlabserver/mainserver.cpp b/src/meshlabserver/mainserver.cpp
index ab9a7c0..28b86c3 100644
--- a/src/meshlabserver/mainserver.cpp
+++ b/src/meshlabserver/mainserver.cpp
@@ -29,7 +29,10 @@
 #include <common/filterscript.h>
 #include <common/meshlabdocumentxml.h>
 #include <common/mlexception.h>
+#include <common/filterparameter.h>
 #include <wrap/qt/qt_thread_safe_memory_info.h>
+#include "../meshlab/mainwindow.h"
+#include <clocale>
 
 #include <QFileInfo>
 
@@ -619,11 +622,11 @@ struct OutProject
 
 int main(int argc, char *argv[])
 {
-
-
     FILE* logfp = stdout;
     FILE* dumpfp = NULL;
     MeshLabApplication app(argc, argv);
+	std::setlocale(LC_ALL, "C");
+	QLocale::setDefault(QLocale::C);
     if(argc == 1)
     {
         commandline::usage();
@@ -645,9 +648,17 @@ int main(int argc, char *argv[])
         exit(-1);
     }
 
-	QSettings st;
-	QVariant mbvar = st.value("MeshLab::System::maxGPUMemDedicatedToGeometry");
-	std::ptrdiff_t maxgpumem = (std::ptrdiff_t)mbvar.toInt() * (float)(1024 * 1024);
+	QSettings settings(MeshLabApplication::organization(),MeshLabApplication::appArchitecturalName(MeshLabApplication::HW_64BIT));
+
+	QVariant xmlgpupar = settings.value(MainWindowSetting::maximumDedicatedGPUMem());
+
+	QDomDocument doc;
+	doc.setContent(xmlgpupar.toString(), false);
+
+	QDomElement paramelem = doc.firstChild().toElement();
+	int gpumemmb = paramelem.attribute("value").toInt();
+
+	std::ptrdiff_t maxgpumem = (std::ptrdiff_t) gpumemmb * (float)(1024 * 1024);
 	vcg::QtThreadSafeMemoryInfo gpumeminfo(maxgpumem);
 
 	MeshDocument meshDocument;
